using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace DemoApp.DataAccess 
{
  public partial class RoleEntityConfiguration 
    : EntityTypeConfiguration<Role>
  {
    public RoleEntityConfiguration()
    {
      HasEntitySetName(@"Roles");
      Map(map => {
        map.ToTable(@"Roles");
      });
      HasKey(e => new { e.RoleId });
 

      Property(e => e.RoleId) 
        .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

      Property(e => e.Name) 
        .HasMaxLength(60);

      Property(e => e.IsAdmin);
 

      HasMany(e => e.SecurableActions)
        .WithMany(e => e.Roles);

      HasMany(e => e.Users)
        .WithMany(e => e.Roles);
    }
  }
}
